(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.limit.limitTree.hisViewController', viewController);
	viewController.$inject = [ '$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'limitService' ];
	function viewController($scope, Constants, layoutConfig, validatorConfig, gridService, authService, limitService) {
		var ctrl = this, limitInfo = $scope.$stateParams.params;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;

		ctrl.init = function() {
			var params = {
					limitHistoryId : limitInfo.limitHistoryId
			};
			authService.view(params).then(function(response) {
				var initLimit = response.data || limitInfo;
				// init general
				limitService.initGeneral(initLimit, $scope, ctrl).then(function() {
					// init limitRule
					limitService.initLimitRule($scope, ctrl);
					ctrl.limit = initLimit;
					if (ctrl.limit.isUnlimited) {
						limitService.resetLimitByUnlimited(ctrl);
					}
				});
			});
		};
	}
})(angular);